{% extends "base.html" %}
{% block body %}
  <form class="form my-2 my-lg-0">
    <input class="form-control mr-sm-2" placeholder="root uri" name="root_uri" value="{{ root_uri }}" type="text">
    <input  class="form-control mr-sm-2" type="text" name="link_prefix" placeholder="link prefix" value="{{ link_prefix }}">
    <input  class="form-control mr-sm-2" type="text" name="global_link_prefix" placeholder="global link prefix" value="{{ global_link_prefix }}">
    <br /><button class="btn btn-outline-success my-2 my-sm-0" type="submit">确定</button>
  </form>
  <br />
  <hr />
  <div><a href="/path/del">empty all hosts</a></div>
  <div><a href="/path/scan">scan all hosts</a></div>
  <div><a href="/path/scan?stop=yes">stop scan</a></div>
  {% if host_ctx %}
    <div class="table-responsive">
      <table class="table table-hover">
        <thead>
          <tr><th width="20">type</th><th>root_uri</th><th>link_prefix</th><th></th></tr>
        </thead>
        <tbody>
          {% for host in host_ctx %}
            <tr>
              <td>d</td>
              <td><a href="/host/list?root_uri={{host[1]}}&link_prefix={{host[2]}}">{{ host[1] }}</td>
              <td>{{ host[2] }}</td>
              <td>
                {% if host[0] == -1 %}
                  <a href="/host/add?root_uri={{ host[1] }}&link_prefix={{ host[2] }}">add</a>
                {% else %}
                  <a href="/host/del?id={{ host[0] }}">del</a>
                  | <a href="/path/scan?root_uri={{ host[1] }}&link_prefix={{ host[2] }}">scan</a>
                  | <a href="/path/del?link_prefix={{ host[2] }}">empty</a>
                {% endif %}
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  {% else %}
    hosts is empty
  {% endif %}
{% endblock %}